<?php

namespace app\rest\model;

use think\Model;

class User extends Model
{
//    设置完成表明
    protected $table = 'xy_user';
    //例子设置主键
    protected $pk = 'id';
    public function setPass($pass)
    {
//        return md5($pass);
        return password_hash($pass,PASSWORD_DEFAULT);
    }

    public function checkPass($id,$pass)
    {
        $user = user::get($id);
        $hashpass = $user->pass;
        var_dump($hashpass);
        // 验证密码操作
        //验证PASS和hashpass是否匹配,不需要传递其他参数
        return password_verify($pass,$hashpass);
    }

}

